
#pragma once

using namespace System::Resources;

namespace ttg_internal
{
	namespace utils
	{
		///<summary>
		/// Loads requred images from resources and provides direct access to them.
		///</summary>
		public ref class ImageKeeper
		{
			private:
				System::Drawing::Icon ^_ttgIcon;
				System::Drawing::Image ^_utilityOn;
				System::Drawing::Image ^_utilityOff;
			public:
				///<summary>
				/// Loads resources. In case of error shows message-box.
				///</summary>
				ImageKeeper()
				{
					//Zeroing.
					_ttgIcon = nullptr;
					_utilityOn = nullptr;
					_utilityOff = nullptr;
					//Loading.
					try
					{
						ResourceManager ^rm =
							gcnew ResourceManager("UtilManager.Images", System::Reflection::Assembly::GetExecutingAssembly());
						_ttgIcon = safe_cast<System::Drawing::Icon ^>(rm->GetObject("ttglib_icon"));
						_utilityOn = safe_cast<System::Drawing::Image ^>(rm->GetObject("utility_on"));
						_utilityOff = safe_cast<System::Drawing::Image ^>(rm->GetObject("utility_off"));
						rm->ReleaseAllResources();
					}
					catch (System::Exception ^ex)
					{
						System::Windows::Forms::MessageBox::Show(ex->ToString(), "Internal error");
					}
				}
				///<summary>
				/// Returns icon for tray.
				///</summary>
				property System::Drawing::Icon ^ttgIcon
				{
					System::Drawing::Icon ^get()
					{ return _ttgIcon; }
				}
				///<summary>
				/// Returns image, that represents active utility.
				/// In case of error returns nullptr.
				///</summary>
				property System::Drawing::Image ^UtilityOn
				{
					System::Drawing::Image ^get()
					{ return _utilityOn; }
				}
				///<summary>
				/// Returns image, that represents unactive utility.
				/// In case of error returns nullptr.
				///</summary>
				property System::Drawing::Image ^UtilityOff
				{
					System::Drawing::Image ^get()
					{ return _utilityOff; }
				}
		};
	}
}
